<%@ page contentType="text/html;charset=UTF-8"%>
<%@ page import="java.io.*"%>
<%@ page import="java.util.*"%>
<%@ page import="java.text.*"%>
<%@ page import="com.gzgi.framework.*"%>
<%@ page import="com.gzgi.framework.util.*"%>
<%@ page import="com.gzgi.framework.context.*"%>
<%@ page import="com.gzgi.framework.desktop.*"%>
<%@ page import="com.gzgi.framework.template.*"%>
<%@ page import="com.gzgi.framework.template.renderer.*"%>
<%
     SecurityContext securityContext = (SecurityContext) request
				.getSession().getAttribute(SecurityContext.SECURITY_CONTEXT);
     LayoutService layoutService = (LayoutService)ContextFactory.getBean("layoutService");
	 TemplateService templateService = (TemplateService) ContextFactory.getBean("templateService");

     UserPanel userPanel = layoutService.getUserPanel(securityContext.getActorId());
		if (userPanel == null) {
			userPanel = layoutService.getUserPanel("system");
		}

		if (userPanel != null && userPanel.getLayout() != null) {
			if (userPanel.getLayout().getTemplateId() != null) {
			  Template template = templateService.getTemplate(userPanel.getLayout().getTemplateId());
			  for(int i=0; i<200; i++){
				Map context = new HashMap();
				context.put("actorId", securityContext.getActorId());
				context.put("contextPath", request.getContextPath());
				context.put("loginUser", securityContext.getUser());
				context.put("securityContext", securityContext);
				context.put("template", template);
				context.put("userPanel", userPanel);

				Map<String, PanelInstance> panelInstances = userPanel
						.getPanelInstances();
				if (panelInstances != null && panelInstances.size() > 0) {
					Iterator<String> iter = panelInstances.keySet().iterator();
					while (iter.hasNext()) {
						String name = iter.next();
						PanelInstance model = (PanelInstance) panelInstances
								.get(name);
						Panel panel = model.getPanel();
						if (panel != null) {
							context.put(name, panel);
							context.put("panel" + name, panel);
							context.put("panel_" + name, panel);
							context.put(panel.getName(), panel);
						}
					}
				}
			  Writer sw = new StringWriter();
			  RendererContainer.evaluate(template, context, sw);
			}
		}
	 }
 %>
